package com.tuyan.aixiang.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {

    public static final String[] WEEK_DAY_CN = {
            "星期日",
            "星期一",
            "星期二",
            "星期三",
            "星期四",
            "星期五",
            "星期六"
    };


    public static String format(Date date, String pattern) {
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.format(date);
    }

    public static String getWeekDay(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int weekday = c.get(Calendar.DAY_OF_WEEK);
        return WEEK_DAY_CN[weekday - 1];
    }


    public static String formatMinSecDuration(Long duration) {
        long minutes = (duration) / (1000 * 60);
        long seconds = (duration % (1000 * 60)) / 1000;
        return minutes + " \' "
                + seconds + "\'\'";
    }

}
